package com.ecjtu.gateway.netty.util;

import java.util.Arrays;

public final class HexUtil {

    public static String encodeByteArr2Hex(byte[] dataArr){
        StringBuilder hexString = new StringBuilder();
        for (byte b : dataArr) {
            String hex = Integer.toHexString(b & 0xFF);
            hexString.append(hex.length() == 1 ? "0" + hex : hex);
        }
        return hexString.toString();
    }

    public static void main(String[] args) {
        System.out.println(encodeByteArr2Hex(new byte[]{(byte) 17,(byte) 18,(byte) 2}));
    }
}
